package com.wanglei.rdd.transform

import org.apache.spark.{SparkConf, SparkContext}

object Spark20_cogroup {

  def main(args: Array[String]): Unit = {

    //
    val conf = new SparkConf().setMaster("local[2]").setAppName("map")
    val sc = new SparkContext(conf)

    val rdd1 = sc.makeRDD(List(
      ("a", 1), ("b", 2), ("c", 3)
    ))

    val rdd2 = sc.makeRDD(List(
      ("a", 101), ("a", 100), ("b", 102)
    ))


    // cogroup = connect + group
    // 连接两个rdd， 并且按照key分组
    rdd1.cogroup(rdd2)
      .collect().foreach(println)

    sc.stop()

  }

}


